package com.link.base.base.knowledge.service;

import com.link.base.base.knowledge.model.Knowledge;
import com.link.core.basic.service.BasicService;

import java.util.List;
import java.util.Map;

/**
 * @author unknown
 * @date unknown
 * @comments 知识库处理
 */
public interface KnowledgeService extends BasicService<Knowledge> {

    /**
     * 知识库统计
     * @param entity 知识库对象
     * @return Knowledge
     */
    Knowledge countCollById(Knowledge entity);

    /**
     * 获取根节点
     * @param knowledge 知识库对象
     * @return List Knowledge
     * @throws Exception
     */
    List<Knowledge> queryRoot(Knowledge knowledge) throws Exception;

    /**
     * 获取树
     * @param root 知识库对象
     * @return List Knowledge
     * @throws Exception
     */
    void queryTreeByRoot(Knowledge root, String publicFlag, long corpId) throws Exception;

    /**
     * 递归查询知识树结构
     * @param entity 知识库对象
     * @param parentPos
     * @param pos
     * @param map
     * @return
     * @throws Exception
     */
    void treeKnowledgeList(Knowledge entity, int parentPos, int pos,Map<String ,List<Knowledge>> map) throws Exception;

    /**
     * 查询知识树节点
     * @param t 知识库对象
     * @return List Knowledge
     * @throws Exception
     */
    List<Knowledge> queryTreeNode(Knowledge t) throws Exception;

    /**
     * 获取知识库树根
     * @param entity 知识库对象
     * @return Knowledge
     * @throws Exception
     */
    Knowledge queryRootByShareId(Knowledge entity) throws Exception;

    /**
     * 获取corpid publicTag
     * @param entity 知识库对象
     * @return Knowledge
     * @throws Exception
     */
    Knowledge queryCorpById(Knowledge entity) throws Exception;

    /**
     * 获取知识库
     * @param entity 知识库对象
     * @return List Knowledge
     * @throws Exception
     */
    List<Knowledge> queryLeafByNode(Knowledge entity) throws Exception;

    /**
     * <p>浏览量加一</p>
     *
     * @author 何启谦
     * @param id 知识库对象ID
     * @return 最新的浏览量
     * @throws Exception
     */
    Integer increasePageviews(Long id) throws Exception;

    /**
     * 移动端-营销助手-查询知识库文章各类型总数
     * @author Tipor
     * @param record
     * @return List Knowledge
     * @throws Exception
     */
    List<Knowledge> queryKnowledgeTypeNum(Knowledge record) throws Exception;

    /**
     * 移动端-经销商平台-查询知识库文章各类型总数
     * @author Tipor
     * @param record
     * @return
     * @throws Exception
     */
    List<Knowledge> queryAppKnowledgeTypeNum(Knowledge record) throws Exception;


    /**
     * 获取知识库的浏览量、点赞量、收藏量、当前用户是否点赞、是否收藏
     *
     * @author ouyangzhenqiang
     * @date 2018/11/7
     * @param record
     * @param userId
     * @return
     * @throws Exception
     */
    void setStatisticsData(Knowledge record, Long userId) throws Exception;

    /**
     * 模糊查询标题,内容
     *
     * @author 朱泊阳
     * @date 2019/5/23
     * @param knowledge
     * @return
     * @throws Exception
     */
    List<Knowledge> queryKnowledgeByExamplePage(Knowledge knowledge) throws Exception;

    /**
     * <p>浏览量pv字段加一，非pageview字段</p>
     * <p>注意：方法名称特意不以update结尾，因为不需要进入mybatis拦截器</p>
     *
     * @author 姚润发
     * @param id 知识库对象id
     * @return
     */
    int increasePV(Long id);
}
